| Conditions | 1 |
| Paths | 1 |
| Total Lines | 125 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /* |
||
| 72 | $(document).ready(function () { |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @constructs Navigation |
||
| 76 | */ |
||
| 77 | var Navigation = function () { |
||
| 78 | |||
| 79 | $.extend(Navigation.prototype, curr); |
||
| 80 | $.extend(Navigation.prototype, nav); |
||
| 81 | $.extend(Navigation.prototype, elements); |
||
| 82 | $.extend(Navigation.prototype, actions); |
||
| 83 | $.extend(Navigation.prototype, settings); |
||
|
|
|||
| 84 | $.extend(Navigation.prototype, resultCircles); |
||
| 85 | $.extend(Navigation.prototype, resultMembers); |
||
| 86 | $.extend(Navigation.prototype, resultLinks); |
||
| 87 | |||
| 88 | this.init(); |
||
| 89 | this.initTransifex(); |
||
| 90 | this.retrieveSettings(); |
||
| 91 | }; |
||
| 92 | |||
| 93 | |||
| 94 | Navigation.prototype = { |
||
| 95 | |||
| 96 | init: function () { |
||
| 97 | elements.initElements(); |
||
| 98 | elements.initUI(); |
||
| 99 | elements.initTweaks(); |
||
| 100 | elements.initAnimationNewCircle(); |
||
| 101 | elements.initExperienceCirclesList(); |
||
| 102 | elements.initExperienceCircleButtons(); |
||
| 103 | //elements.initExperienceMemberDetails(); |
||
| 104 | nav.initNavigation(); |
||
| 105 | }, |
||
| 106 | |||
| 107 | initTransifex: function () { |
||
| 108 | t('circles', 'Personal Circle'); |
||
| 109 | t('circles', 'Hidden Circle'); |
||
| 110 | t('circles', 'Private Circle'); |
||
| 111 | t('circles', 'Public Circle'); |
||
| 112 | |||
| 113 | t('circles', 'Personal'); |
||
| 114 | t('circles', 'Hidden'); |
||
| 115 | t('circles', 'Private'); |
||
| 116 | t('circles', 'Public'); |
||
| 117 | |||
| 118 | t('circles', 'Not a member'); |
||
| 119 | t('circles', 'Member'); |
||
| 120 | t('circles', 'Moderator'); |
||
| 121 | t('circles', 'Admin'); |
||
| 122 | t('circles', 'Owner'); |
||
| 123 | |||
| 124 | |||
| 125 | t('circles', 'Unknown'); |
||
| 126 | t('circles', 'Invited'); |
||
| 127 | t('circles', 'Requesting'); |
||
| 128 | t('circles', 'Blocked'); |
||
| 129 | t('circles', 'Kicked'); |
||
| 130 | }, |
||
| 131 | |||
| 132 | retrieveSettings: function () { |
||
| 133 | var self = this; |
||
| 134 | |||
| 135 | $.ajax({ |
||
| 136 | method: 'GET', |
||
| 137 | url: OC.generateUrl('/apps/circles/settings'), |
||
| 138 | }).done(function (result) { |
||
| 139 | self.retrieveSettingsResult(result) |
||
| 140 | }).fail(function () { |
||
| 141 | self.retrieveSettingsResult({status: -1}); |
||
| 142 | }); |
||
| 143 | }, |
||
| 144 | |||
| 145 | retrieveSettingsResult: function (result) { |
||
| 146 | if (result.status !== 1) { |
||
| 147 | return; |
||
| 148 | } |
||
| 149 | |||
| 150 | curr.allowed_federated = result.allowed_federated; |
||
| 151 | curr.allowed_circles = result.allowed_circles; |
||
| 152 | |||
| 153 | var circleId = window.location.hash.substr(1); |
||
| 154 | if (circleId) { |
||
| 155 | actions.selectCircle(circleId); |
||
| 156 | } |
||
| 157 | } |
||
| 158 | |||
| 159 | }; |
||
| 160 | |||
| 161 | |||
| 162 | /** |
||
| 163 | * @constructs Notification |
||
| 164 | */ |
||
| 165 | var Notification = function () { |
||
| 166 | this.initialize(); |
||
| 167 | }; |
||
| 168 | |||
| 169 | Notification.prototype = { |
||
| 170 | |||
| 171 | initialize: function () { |
||
| 172 | |||
| 173 | //noinspection SpellCheckingInspection |
||
| 174 | var notyf = new Notyf({ |
||
| 175 | delay: 5000 |
||
| 176 | }); |
||
| 177 | |||
| 178 | this.onSuccess = function (text) { |
||
| 179 | notyf.confirm(text); |
||
| 180 | }; |
||
| 181 | |||
| 182 | this.onFail = function (text) { |
||
| 183 | notyf.alert(text); |
||
| 184 | }; |
||
| 185 | |||
| 186 | } |
||
| 187 | |||
| 188 | }; |
||
| 189 | |||
| 190 | OCA.Circles.Navigation = Navigation; |
||
| 191 | OCA.Circles.navigation = new Navigation(); |
||
| 192 | |||
| 193 | OCA.Notification = Notification; |
||
| 194 | OCA.notification = new Notification(); |
||
| 195 | |||
| 196 | }); |
||
| 197 | |||
| 198 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.